const koa = require('koa');
const app = new koa();
const auth = require('./auth');

app.use(async (ctx, next) => {
  console.log('start', ctx.path);
  await next();
})

app.use(auth);

app.use(async (ctx, next) => {
  console.log(ctx.request.path);
  if (ctx.request.path === '/test') {
    ctx.body.response = 'koa index /test';
  }
  await next();
})


app.use(async (ctx, next) => {
  console.log(ctx.request.path);
  if (ctx.request.path === '/rdTest') {
    ctx.body.response = 'koa index /rdTest';
  }
  await next();
})

app.use(async (ctx, next) => {
  console.log('end---------------------');
  await next();
})


let port = 8082;
app.listen(port, () => console.log(`Server started on port ${port}`))
